package fr.aprr.odyssee.client.view;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;
import com.sencha.gxt.core.client.resources.ThemeStyles;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.widget.core.client.ContentPanel;
import com.sencha.gxt.widget.core.client.ContentPanel.ContentPanelAppearance;
import com.sencha.gxt.widget.core.client.FramedPanel.FramedPanelAppearance;
import com.sencha.gxt.widget.core.client.container.BorderLayoutContainer;
import com.sencha.gxt.widget.core.client.container.BorderLayoutContainer.BorderLayoutData;
import com.sencha.gxt.widget.core.client.container.HorizontalLayoutContainer;
import com.sencha.gxt.widget.core.client.container.HorizontalLayoutContainer.HorizontalLayoutData;
import com.sencha.gxt.widget.core.client.container.MarginData;
import com.sencha.gxt.widget.core.client.container.SimpleContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;

public class MainPanel implements IsWidget {
	
	private BorderLayoutContainer con;
	
	VehiculePanel vehiculePanel;
	FlotChart flot;
	CanvasWidget canvas;
	
	@Override
	public Widget asWidget() {
		// TODO Auto-generated method stub
		
		if (con == null) {
		      vehiculePanel = new VehiculePanel();
		      flot = new FlotChart();
		      canvas = new CanvasWidget();
		      
		   // Right Panel
		      con = new BorderLayoutContainer();
		      con.addStyleName("source");
		      con.setHeight("1200px");
		      
		      ContentPanel vehiculePanel = new ContentPanel();
		      vehiculePanel.getHeader().getElement().getStyle().setProperty("backgroundImage", "none");
		      vehiculePanel.getHeader().getElement().getStyle().setProperty("borderTop", "1px solid " + ThemeStyles.get().borderColor());
		      vehiculePanel.setHeadingText("Vehicule");
		      
		      BorderLayoutData datalayout = new BorderLayoutData();
		      datalayout.setMargins(new Margins(5, 0, 5, 5));
		      datalayout.setCollapsible(true);
		      datalayout.setSplit(true);
		      datalayout.setCollapseMini(true);
		      datalayout.setCollapseHidden(true);
		     
		     
		     
		    //  Left Panel
		      VerticalLayoutContainer verticalLayout = new VerticalLayoutContainer();
		      Label label1 = new Label("Test Label 1");
		      label1.addStyleName(ThemeStyles.get().style().border());
		      label1.addStyleName("pad-text white-bg");
		 
		      Label label2 = new Label("Test Label 2");
		      label2.addStyleName(ThemeStyles.get().style().border());
		      label2.addStyleName("pad-text white-bg");
		      
		      Label label3 = new Label("Test Label 3");
		      label3.addStyleName(ThemeStyles.get().style().border());
		      label3.addStyleName("pad-text white-bg");
		 
		      flot.addStyleName(ThemeStyles.get().style().border());
		      flot.addStyleName("pad-text white-bg");
		      
		      canvas.addStyleName(ThemeStyles.get().style().border());
		      canvas.addStyleName("pad-text white-bg");
		      
		      verticalLayout.add(flot, new VerticalLayoutData(1, .5d, new Margins(10, 70, 0, 70)));
		      verticalLayout.add(canvas, new VerticalLayoutData(1, -1320, new Margins(10, 70, 0, 70)));
		      
		      
		      ContentPanel leftPanel = new ContentPanel();
		      leftPanel.getHeader().getElement().getStyle().setProperty("backgroundImage", "none");
		      leftPanel.getHeader().getElement().getStyle().setProperty("borderTop", "1px solid " + ThemeStyles.get().borderColor());
		      leftPanel.setHeadingText("Vehicule Shema");
		      
		      MarginData centerData = new MarginData();
		      centerData.setMargins(new Margins(5));
		      
		      leftPanel.setWidget(verticalLayout);
		      
		     
		     // Add to main Panel
		      con.setWestWidget(vehiculePanel, datalayout);
		      con.setCenterWidget(leftPanel, centerData);
		    }
		
		return con;
	}
}
